package com.software.fanfan.utils;

import com.software.fanfan.entity.vo.Result;

/**
 * result工具类
 *
 * Created by shiyanfei on 2018-01-09.
 */
public class ResultUtil {

    /**
     * 执行成功并返回数据
     *
     * @param object 返回的数据
     * @return Result
     */
    public static Result success(Object object){
        Result result = new Result();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(object);

        return result;
    }

    /**
     * 执行成功无返回数据
     *
     * @return Result
     */
    public Result success(){
        return success(null);
    }

    /**
     * 执行失败
     * @param code 异常代码
     * @param msg 异常信息
     * @return Result
     */
    public Result error(int code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }


}
